package io.gitee.zhangbinhub.admin.route.init

import io.gitee.zhangbinhub.acp.boot.base.BaseInitialization
import io.gitee.zhangbinhub.acp.boot.interfaces.LogAdapter
import io.gitee.zhangbinhub.admin.route.domain.InitDataDomain
import io.gitee.zhangbinhub.admin.route.domain.RouteDomain
import org.springframework.stereotype.Component

@Component
class DataInitialization(
    private val logAdapter: LogAdapter, private val routeDomain: RouteDomain, private val initDataDomain: InitDataDomain
) : BaseInitialization() {
    override val name: String
        get() = "Data Initialization"

    override val order: Int
        get() = 1

    override fun start() {
        routeDomain.getRouteListByRouteIdList(listOf(InitDataDomain.WORK_FLOW_SERVER_API_ROUTE_ID)).let { routeList ->
            if (routeList.isEmpty()) {
                logAdapter.info(">>>>>>>>>>>>>>>>>>>> begin init route data...")
                initDataDomain.doInitRoute()
                logAdapter.info(">>>>>>>>>>>>>>>>>>>> init route data has finished!")
            }
        }
    }

    override fun stop() {}
}